home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 051-075 / disk_069 / spool / spool.c < prev    next >
C/C++ Source or Header  |  1992-05-06  |  2KB  |  109 lines

  1. /* SPOOL.c - queue print file program */
  2.  
  3. /*
  4. **    Date written: 04/23/86
  5. **    Author: Tim Holloway
  6. **        Compuserve: 73026,2026
  7. **        Bix: tholloway
  8. **        Fido node: 112/1 (Casa Mi Amiga).
  9. **
  10. **    As featured in Ami Project Magazine.
  11. **
  12. **
  13. **    Version: 1.0
  14. **
  15. **    Copyright (C) 1986, by Tim Holloway.  This program may be
  16. **    freely distributed for non-commercial use only.  Use for commercial
  17. **    purposes without the express permission of the author is a violation
  18. **    of copyright law.
  19. **
  20. **    Description:
  21. **       This program accepts as input one or more file names.
  22. **    These names are passed via a message port to the SPOOLER program,
  23. **    which prints the files.
  24. **
  25. **    Change History: none.
  26. **    Usage: See below.
  27. */
  28.  
  29. /* Basic Amiga system definitions */
  30.  
  31. #include <exec/types.h>
  32. #include <intuition/intuition.h>
  33. #include <libraries/dos.h>
  34.  
  35. /* more mundane definitions */
  36.  
  37. #include "stdio.h"
  38. #include "spool.h"
  39.  
  40. /* define login and logout stuff in the following #include: */
  41. #include "login.cx"
  42.  
  43.  
  44. usage()
  45. {
  46.     printf ("SPOOLing program v1.0 by Tim Holloway\n");
  47.     printf ("Usage: SPOOL filename1 [filename2 [filename3...]]\n");
  48. }
  49.  
  50. SPOOLmsg packet = {{NULL, NULL, 0}, '?', ""};
  51.  
  52. error (msg)
  53. char *msg;
  54. {
  55.     fprintf (stderr, "%s\n", msg);
  56. }
  57.  
  58.  
  59. main (argc, argv)
  60. int argc;
  61. char *argv[];
  62. {
  63.    int i;
  64.    PORTPAIR ports; 
  65.  
  66.    if ((argc < 2) || (argv[1][1] == '?'))
  67.    {
  68.       usage();
  69.       exit(10);
  70.    }
  71.  
  72.    if (NOT LogInPort (SPOOL_ME, &ports, &packet))
  73.    {
  74.       error ("SPOOLER program is inactive\n");
  75.       exit(15);
  76.    }
  77.  
  78. /* printf ("message port for %s is at %lx\n", SPOOL_ME, ports[OUTPORT]); */
  79.  
  80.    for (i = 1; i < argc; i++)
  81.    {
  82.       if (argv[i][0] == '-')    /* command to SPOOLER */
  83.     strcpy (packet.filename, argv[i]);
  84.       else
  85.       {
  86.     ExpandPath (argv[i], packet.filename);
  87.     if (packet.filename[0] == NUL)
  88.     {
  89.         printf ("ERROR: file \"%s\" could not be found!\n", argv[i]);
  90.         continue;
  91.     }
  92.       }
  93.  
  94.       packet.minfo.mn_ReplyPort = ports[INPORT];    /* return address */
  95.  
  96. /* printf ("send/w reply port at %lx\n", packet.minfo.mn_ReplyPort); */
  97.  
  98.       packet.minfo.mn_Length = strlen(packet.filename)+1;
  99.  
  100. /* printf ("===Send to spool...\n"); */
  101.  
  102.       PutMsg (ports[OUTPORT], &packet);
  103.       WaitPort(ports[INPORT]);
  104.       (VOID) GetMsg (ports[INPORT]);
  105.       if (packet.log_status == LOG_OUT) break;    /* ouch! forced off! */
  106.    }
  107.    LogOutPort (&ports, &packet);
  108. }
  109.